import request from './request'

// 课程相关API接口

export interface Course {
  id: number
  name: string
  subject_id: number
  total_stages: number
  total_price: number
  description?: string
  status: string
  created_at?: string
  updated_at?: string
}

export interface CourseListResponse {
  items: Course[]
  total: number
  page: number
  size: number
}

/**
 * 获取课程列表
 */
export const getCourses = (params?: {
  page?: number
  size?: number
  name?: string
  subject_id?: number
}): Promise<CourseListResponse> => {
  return request.get('/courses/', { params })
}

/**
 * 创建课程
 */
export const createCourse = (data: Partial<Course>): Promise<Course> => {
  return request.post('/courses/', data)
}

/**
 * 更新课程
 */
export const updateCourse = (id: number, data: Partial<Course>): Promise<Course> => {
  return request.put(`/courses/${id}`, data)
}

/**
 * 删除课程
 */
export const deleteCourse = (id: number): Promise<void> => {
  return request.delete(`/courses/${id}`)
}
